package promotion

import (
	sqlc "bp/db/sqlc"
	"bp/internal/render"

	// sharedConv "bp/internal/rpcserver/shared/conv"
	sharedVld "bp/internal/rpcserver/shared/vld"
	"bp/internal/service/entity/promotion"
	"bp/internal/util"
	promotionGrpc "bp/rpc/gen/mwebapi/mpromotion"
	"context"
)

// VldListAvailablePromotionsReq 验证列出可用的促销活动请求
func (s *PromotionMWebApiImp) VldListAvailablePromotionsReq(ctx context.Context, q *sqlc.Queries, req *promotionGrpc.ListAvailablePromotionsReq) (ptr *promotion.ListAvailablePromotionsOfUseSceneParam, err error) {
	slog := util.NewContextLogger(ctx, s.slog)
	token := util.GetAuthorizationToken(ctx)
	if !sharedVld.IsIssuer(req.Issuer) {
		err = render.InvalidArgumentValue("issuer")
		return
	}
	if !sharedVld.IsOfferUseScene(req.UseScene) {
		err = render.InvalidArgumentValue("use_scene")
		return
	}
	ptr = &promotion.ListAvailablePromotionsOfUseSceneParam{
		BrandID:  token.BrandID,
		Issuer:   req.Issuer,
		UseScene: req.UseScene,
	}
	slog.Infof("offer_imp/query_vld.VldListAvailablePromotionsReq ok")
	return
}
